package simulator.implementation.agent;
import javax.vecmath.Vector3d;

import simbad.sim.RangeSensorBelt;
import simbad.sim.RobotFactory;
import simulator.meta.agent.ControlledAgent;
public class BumperRobot extends ControlledAgent{
	//Constants:
	private final byte NUMBER_OF_BUMPER_SENSORS = 10;
	//Attributes:
	private RangeSensorBelt bumpers;
	//Constructor: 
	public BumperRobot(Vector3d position, String name) {
		super(position, name);
		this.step = 0;
		this.turn = 0;
		this.bumpers = RobotFactory.addBumperBeltSensor(this, this.NUMBER_OF_BUMPER_SENSORS);
	}
	//Methods:
	public void initBehavior() {}

	public void performBehavior() {
		this.setTranslationalVelocity(this.step);
		this.setRotationalVelocity((Math.PI/180)*this.turn);
		//Cada 10 tiempos del ambiente, se obtienen mediciones:
		if((this.getCounter()%10)==0){
			boolean hit;
			System.out.println("=========================");
			//Por cada sensor...
			for(int i = 0;i<this.bumpers.getNumSensors();i++){
				//Obtener si detecta impacto.
				hit = this.bumpers.hasHit(i);
				if(hit){
					//Si detecta algo, entonces lo imprimimos.
					System.out.println("Bmp "+i+": "+hit);
				}
			}
		}
	}
}
